function initial(){
    var dom = document.getElementById("testBox2");
    var myChart = echarts.init(dom);
    var app = {};
    option = null;
    var name_title = "全国新冠肺炎疫情数据"
var subname = '截止4月30日24点'
var nameColor = 'rgb(255,255,255)'
var name_fontFamily = '等线'
var subname_fontSize = 36
var name_fontSize = 40
var mapName = 'china'
var data = [
    {name:"北京",value:593},
    {name:"天津",value:190},
    {name:"河北",value:328},
    {name:"山西",value:197},
    {name:"内蒙古",value:200},
    {name:"辽宁",value:146},
    {name:"吉林",value:111},
    {name:"黑龙江",value:939},
    {name:"上海",value:647},
    {name:"江苏",value:653},
    {name:"浙江",value:1268},
    {name:"安徽",value:991},
    {name:"福建",value:355},
    {name:"江西",value:937},
    {name:"山东",value:787},
    {name:"河南",value:1276},
    {name:"湖北",value:68128},
    {name:"湖南",value:1019},
    {name:"重庆",value:579},
    {name:"四川",value:561},
    {name:"贵州",value:147},
    {name:"云南",value:185},
    {name:"西藏",value:1},
    {name:"陕西",value:306},
    {name:"甘肃",value:139},
    {name:"青海",value:18},
    {name:"宁夏",value:75},
    {name:"新疆",value:76},
    {name:"广东",value:1588},
    {name:"广西",value:254},
    {name:"海南",value:168},
    {name:"澳门",value:45},
    {name:"香港",value:1037},
    {name:"台湾",value:429},
    ];
    
var geoCoordMap = {};
var toolTipData = [ 
    {name:"北京",value:[{name:"累计确诊",value:593},{name:"累计治愈",value:542},{name:"累计死亡",value:9}]},
    {name:"天津",value:[{name:"累计确诊",value:190},{name:"累计治愈",value:183},{name:"累计死亡",value:3}]},
    {name:"河北",value:[{name:"累计确诊",value:328},{name:"累计治愈",value:318},{name:"累计死亡",value:6}]},
    {name:"山西",value:[{name:"累计确诊",value:197},{name:"累计治愈",value:164},{name:"累计死亡",value:0}]},
    {name:"内蒙古",value:[{name:"累计确诊",value:200},{name:"累计治愈",value:150},{name:"累计死亡",value:1}]},
    {name:"辽宁",value:[{name:"累计确诊",value:146},{name:"累计治愈",value:143},{name:"累计死亡",value:2}]},
    {name:"吉林",value:[{name:"累计确诊",value:111},{name:"累计治愈",value:99},{name:"累计死亡",value:1}]},
    {name:"黑龙江",value:[{name:"累计确诊",value:939},{name:"累计治愈",value:587},{name:"累计死亡",value:13}]},
    {name:"上海",value:[{name:"累计确诊",value:647},{name:"累计治愈",value:599},{name:"累计死亡",value:7}]},
    {name:"江苏",value:[{name:"累计确诊",value:653},{name:"累计治愈",value:648},{name:"累计死亡",value:0}]},
    {name:"浙江",value:[{name:"累计确诊",value:1268},{name:"累计治愈",value:1263},{name:"累计死亡",value:1}]},
    {name:"安徽",value:[{name:"累计确诊",value:991},{name:"累计治愈",value:985},{name:"累计死亡",value:6}]},
    {name:"福建",value:[{name:"累计确诊",value:355},{name:"累计治愈",value:353},{name:"累计死亡",value:1}]},
    {name:"江西",value:[{name:"累计确诊",value:937},{name:"累计治愈",value:936},{name:"累计死亡",value:1}]},
    {name:"山东",value:[{name:"累计确诊",value:787},{name:"累计治愈",value:772},{name:"累计死亡",value:7}]},
    {name:"河南",value:[{name:"累计确诊",value:1276},{name:"累计治愈",value:1254},{name:"累计死亡",value:22}]},
    {name:"湖北",value:[{name:"累计确诊",value:68128},{name:"累计治愈",value:63616},{name:"累计死亡",value:4512}]},
    {name:"湖南",value:[{name:"累计确诊",value:1019},{name:"累计治愈",value:1015},{name:"累计死亡",value:4}]},
    {name:"重庆",value:[{name:"累计确诊",value:579},{name:"累计治愈",value:573},{name:"累计死亡",value:6}]},
    {name:"四川",value:[{name:"累计确诊",value:561},{name:"累计治愈",value:558},{name:"累计死亡",value:3}]},
    {name:"贵州",value:[{name:"累计确诊",value:147},{name:"累计治愈",value:145},{name:"累计死亡",value:2}]},
    {name:"云南",value:[{name:"累计确诊",value:185},{name:"累计治愈",value:181},{name:"累计死亡",value:2}]},
    {name:"西藏",value:[{name:"累计确诊",value:1},{name:"累计治愈",value:1},{name:"累计死亡",value:0}]},
    {name:"陕西",value:[{name:"累计确诊",value:306},{name:"累计治愈",value:253},{name:"累计死亡",value:3}]},
    {name:"甘肃",value:[{name:"累计确诊",value:139},{name:"累计治愈",value:137},{name:"累计死亡",value:2}]},
    {name:"青海",value:[{name:"累计确诊",value:18},{name:"累计治愈",value:18},{name:"累计死亡",value:0}]},
    {name:"宁夏",value:[{name:"累计确诊",value:75},{name:"累计治愈",value:75},{name:"累计死亡",value:0}]},
    {name:"新疆",value:[{name:"累计确诊",value:76},{name:"累计治愈",value:73},{name:"累计死亡",value:3}]},
    {name:"广东",value:[{name:"累计确诊",value:1588},{name:"累计治愈",value:1557},{name:"累计死亡",value:8}]},
    {name:"广西",value:[{name:"累计确诊",value:254},{name:"累计治愈",value:252},{name:"累计死亡",value:2}]},
    {name:"海南",value:[{name:"累计确诊",value:168},{name:"累计治愈",value:162},{name:"累计死亡",value:6}]},
    {name:"香港",value:[{name:"累计确诊",value:1037},{name:"累计治愈",value:846},{name:"累计死亡",value:4}]},
    {name:"澳门",value:[{name:"累计确诊",value:45},{name:"累计治愈",value:35},{name:"累计死亡",value:0}]},
    {name:"台湾",value:[{name:"累计确诊",value:429},{name:"累计治愈",value:322},{name:"累计死亡",value:6}]},
    
];

/*获取地图数据*/
myChart.showLoading();
var mapFeatures = echarts.getMap(mapName).geoJson.features;
myChart.hideLoading();
mapFeatures.forEach(function(v) {
    // 地区名称
    var name = v.properties.name;
    // 地区经纬度
    geoCoordMap[name] = v.properties.cp;

});

// console.log("============geoCoordMap===================")
// console.log(geoCoordMap)
// console.log("================data======================")
console.log(data)
console.log(toolTipData)
var max = 480,
    min = 9; // todo 
var maxSize4Pin = 100,
    minSize4Pin = 20;

var convertData = function(data) {
    var res = [];
    for (var i = 0; i < data.length; i++) {
        var geoCoord = geoCoordMap[data[i].name];
        if (geoCoord) {
            res.push({
                name: data[i].name,
                value: geoCoord.concat(data[i].value),
            });
        }
    }
    return res;
};
    option = {
        title: {
        text: name_title,
        subtext: subname,
        x: 'center',
        textStyle: {
            color: nameColor,
            fontFamily: name_fontFamily,
            fontSize: name_fontSize
        },
        subtextStyle:{
            fontSize:subname_fontSize,
            fontFamily:name_fontFamily
        }
    },
    tooltip: {
        trigger: 'item',
        formatter: function(params) {
            if (typeof(params.value)[2] == "undefined") {
                var toolTiphtml = ''
                for(var i = 0;i<toolTipData.length;i++){
                    if(params.name==toolTipData[i].name){
                        toolTiphtml += toolTipData[i].name+':<br>'
                        for(var j = 0;j<toolTipData[i].value.length;j++){
                            toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
                        }
                    }
                }
                console.log(toolTiphtml)
                // console.log(convertData(data))
                return toolTiphtml;
            } else {
                var toolTiphtml = ''
                for(var i = 0;i<toolTipData.length;i++){
                    if(params.name==toolTipData[i].name){
                        toolTiphtml += toolTipData[i].name+':<br>'
                        for(var j = 0;j<toolTipData[i].value.length;j++){
                            toolTiphtml+=toolTipData[i].value[j].name+':'+toolTipData[i].value[j].value+"<br>"
                        }
                    }
                }
                console.log(toolTiphtml)
                // console.log(convertData(data))
                return toolTiphtml;
            }
        }
    },
    // legend: {
    //     orient: 'vertical',
    //     y: 'bottom',
    //     x: 'right',
    //     data: ['credit_pm2.5'],
    //     textStyle: {
    //         color: '#fff'
    //     }
    // },
    visualMap: {
        show: true,
        min: 1,
        max: 68128,
        left: 'left',
        top: 'bottom',
        showLabel: !0,
        text: ["高", "低"],
        textStyle: {
            color: '#fff',
            fontSize: 20
        },
        pieces: [{
            gt: 60000,
            label: "> 60,000 人",
            color: "rgb(120,0,0)"
        }, {
            gte: 1000,
            lte: 2000,
            label: "1,000 - 2,000 人",
            color: "rgb(190,41,41)"
        }, {
            gte: 500,
            lte: 999,
            label: "500 - 999 人",
            color: "rgb(224,82,82)"
        }, {
            gte: 100,
            lte: 499,
            label: "100 - 499 人",
            color: "rgb(235,122,122)"
        }, {
            gte : 10,
            lte : 99,
            label  : '10 - 99 人',
            color: "rgb(245,163,163)"
        },{
            gte : 0,
            lte : 9,
            label  : '少于10 人',
            color: "rgb(255,204,204)"
        }],
    },
    /*工具按钮组*/
    // toolbox: {
    //     show: true,
    //     orient: 'vertical',
    //     left: 'right',
    //     top: 'center',
    //     feature: {
    //         dataView: {
    //             readOnly: false
    //         },
    //         restore: {},
    //         saveAsImage: {}
    //     }
    // },
    geo: {
        show: true,
        map: mapName,
        label: {
            normal: {
                show: false
            },
            emphasis: {
                show: false,
            }
        },
        roam: true,
        itemStyle: {
            normal: {
                areaColor: '#031525',
                borderColor: '#3B5077',
            },
            emphasis: {
                areaColor: '#2B91B7',
            }
        }
    },
    series: [{
            name: '散点',
            type: 'scatter',
            coordinateSystem: 'geo',
            //data: convertData(data),
            symbolSize: function(val) {
                return val[2] / 10;
            },
            label: {
                normal: {
                    formatter: '{b}',
                    position: 'right',
                    show: true
                },
                emphasis: {
                    show: true
                }
            },
            itemStyle: {
                normal: {
                    color: '#05C3F9'
                }
            }
        },
        {
            type: 'map',
            map: mapName,
            geoIndex: 0,
            aspectScale: 0.75, //长宽比
            showLegendSymbol: false, // 存在legend时显示
            label: {
                normal: {
                    show: true
                },
                emphasis: {
                    show: false,
                    textStyle: {
                        color: '#fff'
                    }
                }
            },
            roam: true,
            itemStyle: {
                normal: {
                    areaColor: '#031525',
                    borderColor: '#3B5077',
                },
                emphasis: {
                    areaColor: '#2B91B7'
                }
            },
            animation: false,
            data: data
        },
    ]
    };
    ;
    if (option && typeof option === "object") {
            myChart.setOption(option, true);
        }
}